home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gfxfx / putpic.pas < prev    next >
Pascal/Delphi Source File  |  1994-03-20  |  1KB  |  60 lines

  1.  
  2. {$g+}
  3. program displaypackedpic;
  4. { display packed picture in mode 13h, by Bas van Gaalen, Holland, PD }
  5. uses dos,crt;
  6. var
  7.   infile : file;
  8.   palette : array[0..767] of byte;
  9.   infname : pathstr;
  10.   i,num,ofs : word;
  11.   inbyte : byte;
  12.  
  13. procedure setpalette(var pal); assembler;
  14. asm
  15.   push ds
  16.   mov dx,03c8h
  17.   xor ax,ax
  18.   out dx,al
  19.   inc dx
  20.   lds si,pal
  21.   mov cx,0300h
  22.   rep outsb
  23.   pop ds
  24. end;
  25.  
  26. begin
  27.   { file i/o }
  28.   if paramstr(1) = '' then begin
  29.     write(' infile: '); readln(infname); end else infname := paramstr(1);
  30.   assign(infile,infname);
  31.   reset(infile,1);
  32.   if ioresult <> 0 then begin
  33.     writeln('error opening ',infname); halt; end;
  34.  
  35.   { set graphics and palette }
  36.   asm mov ax,13h; int 10h; end;
  37.   blockread(infile,palette,768);
  38.   setpalette(palette);
  39.  
  40.   { unpack picture to screen }
  41.   ofs := 0;
  42.   while filepos(infile) < filesize(infile) do begin
  43.     blockread(infile,inbyte,1);
  44.     if inbyte = 0 then begin
  45.       blockread(infile,inbyte,1);
  46.       blockread(infile,num,2);
  47.       for i := 0 to num-1 do mem[sega000:ofs+i] := inbyte;
  48.       inc(ofs,num);
  49.     end else begin
  50.       mem[sega000:ofs] := inbyte;
  51.       inc(ofs);
  52.     end;
  53.   end;
  54.   close(infile);
  55.  
  56.   { wait for key and clearkeybuf }
  57.   repeat until keypressed; while keypressed do readkey;
  58.   asm mov ax,3; int 10h; end;
  59. end.
  60.